using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public static class UIUtil
    {
        public static void SetFlip(Transform transform, bool isFlip, RectTransform.Axis direction = default)
        {
            if (transform == null)
            {
                return;
            }
            var scale = transform.localScale;
            switch (direction)
            {
                case RectTransform.Axis.Horizontal:
                    scale.x = isFlip ? (scale.x > 0 ? scale.x * -1 : scale.x) : (scale.x < 0 ? scale.x * -1 : scale.x);
                    break;
                case RectTransform.Axis.Vertical:
                    scale.y = isFlip ? (scale.y > 0 ? scale.y * -1 : scale.y) : (scale.y < 0 ? scale.y * -1 : scale.y);
                    break;
                default:
                    break;
            }
            transform.localScale = scale;
        }
    }
}
